<?php
	$title='Send Comment';
?>
<?php include('./fns_all.php'); ?>
<?php include('./views/layouts/_header.php'); ?>
<?php include('./views/layouts/_left.php'); ?>


<?php
if (isset($_GET['send']) && $_GET['send'] == "true")
{
	if (isset($_POST['user']))
	{
		$user = $_POST['user'];

		if ($user == '')
		{
			unset($user);
		}
	}
	if (isset($_POST['message']))
	{
		$message = $_POST['message'];

		if ($message == '')
		{
			unset($message);
		}
	}
	
	if (isset($user) && isset($message))
	{
		$email = "mitchy80@gmail.com"; 
		$subject = "From: $user"; 
		$mail_sent = @mail( $email, $subject, $message, "From: admin@fmaniac.com" ); 
		echo $mail_sent ? "Mail sent" : "Mail failed";
	}
}else {
	echo '<form action="'.$_SERVER['PHP_SELF'].'?send=true" method="post">';
	printf ("<br/><table>
	
			<tr>
				<td>From: </td>
				<td><input type='text' name='user'
				value=''
				size='20'
				maxsize='20'> </td>
			</tr>
			<tr>
				<td>Message: </td>
				<td><textarea rows='6' cols='30' name='message'>
					</textarea> 
				</td>
			</tr>
			<tr>
				<td colspan='2'><input type='submit'  value='Send'/><td>
			</tr>
			
	         </table>");
	echo '</form>';
}
?>



<?php include('./views/layouts/_footer.php'); ?>